#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
const int M = 1e5 + 5;

int n, m, L, V, d[N], v[N], a[N], p[M], tot;

struct range {
    int l;
    int r;
} q[N];

int cmp(range r1, range r2) {
    if (r1.l == r2.l) {
        int len1 = r1.r - r1.l + 1;
        int len2 = r2.r - r2.l + 1;
        if (len1 == len2) {
            return 0;
        }
        return len1 < len2 ? -1 : 1;
    }
    return r1.l < r2.l ? -1 : 1;
}

inline int detectors(int x) { // The count of detectors within [0, x]
    if (x >= p[m]) {
        return m;
    }
    return upper_bound(p + 1, p + m + 1, x) - p - 1;
}

inline int detectors_exclusive(int x) { // The count of detectors within [0, x)
    if (x > p[m]) {
        return m;
    }
    return lower_bound(p + 1, p + m + 1, x) - p - 1;
}

inline int detectors(int x0, int x) { // The count of detectors within [x0, x]
    return detectors(x) - detectors_exclusive(x0);
}

inline int detectors_exfirst(int x0, int x) { // The count of detectors within (x0, x]
    return detectors(x) - detectors(x0);
}

inline int detectors_exlast(int x0, int x) { // The count of detectors within [x0, x)
    return detectors_exclusive(x) - detectors_exclusive(x0);
}

inline void record_car(int cnt0, int cnt1) {
    q[++tot].l = cnt0 + 1;
    q[tot].r = cnt1;
}

int cnt_too_fast(int i) {
    if (a[i] == 0) {
        if (v[i] > V) {
            int cnt = detectors(d[i], L);
            if (cnt > 0) {
                int cnt1 = detectors(L);
                int cnt0 = detectors_exclusive(d[i]);
                record_car(cnt0, cnt1);
                return cnt;
            }
        }
        return 0;
    }
    if (a[i] > 0) {
        if (v[i] > V) {
            int cnt = detectors(d[i], L);
            if (cnt > 0) {
                int cnt1 = detectors(L);
                int cnt0 = detectors_exclusive(d[i]);
                record_car(cnt0, cnt1);
            }
            return cnt;
        }
        int x0 = (V * V - v[i] * v[i]) / (2 * a[i]);
        int cnt = detectors_exfirst(d[i] + x0, L);
        if (cnt > 0) {
            int cnt1 = detectors(L);
            int cnt0 = detectors(d[i] + x0);
            record_car(cnt0, cnt1);
        }
        return cnt;
    } else {
        if (v[i] <= V) {
            return 0;
        }
        int x0 = (-V * V + v[i] * v[i]) / (-2 * a[i]);
        int cnt = detectors_exlast(d[i], d[i] + x0);
        if (cnt > 0) {
            int cnt1 = detectors_exclusive(d[i] + x0);
            int cnt0 = detectors_exclusive(d[i]);
            record_car(cnt0, cnt1);
        }
        return cnt;
    }
}

int solve1() {
    int ans = 0;
    for (register int i = 1; i <= n; i++) {
        if (cnt_too_fast(i) > 0) {
            ans++;
        }
    }
    return ans;
}

int solve2() {
    if (tot == 0) {
        return m;
    }
    //sort(q + 1, q + tot + 1, cmp);
    int n0 = q[1].r, cnt = 1;
    for (int i = 2; i <= tot; i++) {
        if (q[i].l > n0) {
            cnt++;
            n0 = q[i].r;
        }
        if (q[i].r < n0) {
            n0 = q[i].r;
        }
    }
    return m - cnt;
}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    int T;
    cin >> T;
    while (T--) {
        memset(d, 0, sizeof(d));
        memset(v, 0, sizeof(v));
        memset(a, 0, sizeof(a));
        memset(p, 0, sizeof(p));
        memset(q, 0, sizeof(q));
        tot = 0;
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++) {
            cin >> d[i] >> v[i] >> a[i];
        }
        for (int i = 1; i <= m; i++) {
            cin >> p[i];
        }
        cout << solve1() << " " << solve2()  << endl;
    }
    return 0;
}
